/*
 * @(#)IndividualController.java $version 2011. 5. 19.
 *
 */

package org.doit.android.bobple.server.controller;

import java.util.HashMap;

import org.doit.android.bobple.server.bo.IndividualBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author Choi HongKi
 */
@Controller
public class IndividualController {
	//	private static final Logger LOGGER = LoggerFactory.getLogger(IndividualController.class);

	@Autowired
	private IndividualBO individualBO;

	@RequestMapping(value = "/individual/getRecentLunchHistory")
	public ModelAndView getRecentLunchHistory(@RequestParam("user_id") String userId) {
		HashMap<String, Object> resultMap = new HashMap<String, Object>();

		try {
			resultMap.put("success", true);
			resultMap.put("value", individualBO.getRecentLunchHistory(userId));

			return new ModelAndView("defaultJsonView", resultMap);
		} catch (Exception ex) {
			resultMap.put("success", false);
		}

		return new ModelAndView("defaultJsonView", resultMap);
	}

	@RequestMapping(value = "/individual/getUserIsAuthorized")
	public ModelAndView getUserIsAuthorized(@RequestParam("user_id") String userId, @RequestParam("password") String password) {
		HashMap<String, Object> resultMap = new HashMap<String, Object>();

		try {
			resultMap.put("value", individualBO.getUserIsAuthorized(userId, password));
			resultMap.put("success", true);

			return new ModelAndView("defaultJsonView", resultMap);
		} catch (Exception ex) {
			resultMap.put("success", false);
		}

		return new ModelAndView("defaultJsonView", resultMap);
	}
}